package com.tensquare.service;

import com.tensquare.dao.BaseDao;
import com.tensquare.entity.PageResult;
import com.tensquare.pojo.Label;
import com.tensquare.util.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @ClassName BaseService
 * @Description: TODO
 * @Author zhangzheng
 * @Date 2019/12/16 0016
 **/
@Service
public class BaseService {
    @Autowired
    private BaseDao baseDao;

    @Autowired
    IdWorker idWorker;

    public void addLable(Label label) {
        Long id = idWorker.nextId();
        label.setId(id+"");
        baseDao.save(label);
    }

    public List<Label> getLabelList() {
        return baseDao.findAll();
    }

    public Label getLabelById(String labelId) {
        return baseDao.findById(labelId).get();
    }

    public Label UpdateByLabel(String labelId,Label label) {
        label.setId(labelId);
        return baseDao.save(label);
    }

    public void deleteLabelById(String labelId) {
        baseDao.deleteById(labelId);
    }

    public PageResult<Label> search(Integer page, Integer size) {
        /*List<Label> labels = baseDao.findAll();*/
        return null;
    }
}
